package objects;

import java.text.Collator;
import java.util.Locale;

import ForParser.Parser;

public class Mot implements Comparable<Mot>{
	private String mot;
	private String document;
	private String balise;
	private int ponderation;
	
	public Mot(String mot, String document, String balise) {
		//ajouter delimitters mots TODO
		this.mot = mot.replace("'"," ");
		this.document =document;
		this.balise = balise;
		this.ponderation = Parser.getPonderationFromBalise(balise);
	}
	
	public String toString(){
		return (mot + " " + document + " " + balise);
	}
	
	public String getBalise() {
		return balise;
	}
	
	public String getDocument() {
		return document;
	}
	public String getMot() {
		return mot;
	}
	
	public void setPonderation(int ponderation) {
		this.ponderation = ponderation;
	}
	
	public int getPonderation() {
		return ponderation;
	}

	public int compareTo(Mot mot) {
		//pour se premunir des accents ...
		Collator compareOperator = Collator.getInstance (Locale.FRENCH);
		compareOperator.setStrength (Collator.PRIMARY);
		
		if( compareOperator.compare(this.getMot(), mot.getMot()) ==0  && this.getDocument().equalsIgnoreCase(mot.getDocument() ))
			return 0;
		else
		return -10;
	}
}
